package design.pattern.策略模式;

import java.util.HashMap;
import java.util.Map;

public class CashFactory {

    private static CashFactory cashFactory = new CashFactory();

    private CashFactory(){}

    private static Map<String, CashSuper> factory = new HashMap<>();
    static {
        factory.put(CashTypeEnum.CASH_NORMAL.getKey(), new CashNormal());
        factory.put(CashTypeEnum.CASH_REBATE.getKey(), new CashRebate(0.8));
        factory.put(CashTypeEnum.CASH_RETURN.getKey(), new CashReturn(300, 80));
    }

    public CashSuper getCash(CashTypeEnum type){
        return factory.get(type.getKey());
    }

    public static CashFactory getInstance(){
        return cashFactory;
    }
}

